package queue

import (
	"container/list"
	"fmt"
)

type ListQueue struct {
	queue list.List
}

func (c *ListQueue) Enqueue(value any) {
	c.queue.PushBack(value)
}

func (c *ListQueue) Dequeue() error {
	if c.queue.Len() > 0 {
		ele := c.queue.Front()
		c.queue.Remove(ele)
	}
	return fmt.Errorf("pop Error: Queue is empty")
}

func (c *ListQueue) Front() (any, error) {
	if c.queue.Len() > 0 {
		if val, ok := c.queue.Front().Value.(any); ok {
			return val, nil
		}
		return "", fmt.Errorf("peep Error: Queue Datatype is incorrect")
	}
	return "", fmt.Errorf("peep Error: Queue is empty")
}

func (c *ListQueue) Size() int {
	return c.queue.Len()
}

func (c *ListQueue) Empty() bool {
	return c.queue.Len() == 0
}
